#include "xinzeng.h"
#include "ui_xinzeng.h"
#include <QMessageBox>
#include <QSqlQuery>
xinzeng::xinzeng(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::xinzeng)
{
    ui->setupUi(this);
    connect(ui->pushButton,&QPushButton::clicked,this, &xinzeng::pushButtonClicked);
}

xinzeng::~xinzeng()
{
    delete ui;
}
void xinzeng::setUserData(const QMap<QString, QVariant>& data) {
    ui->editAccount->setText(data["account"].toString());
    ui->editPhone->setText(data["phone"].toString());
    ui->editDept->setText(data["department"].toString());
    ui->editStatus->setText(data["status"].toString());
    ui->dateTimeEdit->setDateTime(data["startTime"].toDateTime());
}

QMap<QString, QVariant> xinzeng::getUserData() const
{
    QMap<QString, QVariant> data;
    data["account"] = ui->editAccount->text().trimmed();
    data["phone"] = ui->editPhone->text().trimmed();
    data["department"] = ui->editDept->text().trimmed();
    data["status"] = ui->editStatus->text().trimmed();
    data["startTime"] = ui->dateTimeEdit->dateTime();
    return data;
}
void xinzeng::pushButtonClicked()
{
       accept(); // 关键！设置对话框返回值为 Accepted
       this->close();
}
void xinzeng::on_cancelButton_clicked()
{
   this->close(); // 取消操作，关闭对话框并返回 Rejected 状态
}
